package com.hc.sss.hgw.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hc.sss.common.ResultMap;
import com.hc.sss.pojo.User;
import com.hc.sss.pojo.Wallet;
import com.hc.sss.pojo.WstLogMoneys;
import com.hc.sss.service.WalletService;
import com.hc.sss.service.WstLogMoneysService;

@Controller
@RequestMapping("/WstLogMoneys")
public class WstLogMoneysController {
	
	@Autowired
	WstLogMoneysService logMoneysService;
	
	@Autowired
	WalletService walletService;
	
	@RequestMapping("/list")
	@ResponseBody
	public ResultMap<WstLogMoneys> findConservatorList(WstLogMoneys wstLogMoneys,Integer page,Integer limit,HttpServletRequest request){
		Map<String, Object> paramMap = new HashMap<>();
		User user = (User) request.getSession().getAttribute("user");
		paramMap.put("page", page);
		paramMap.put("limit", limit);
		paramMap.put("wlmUserId", user.getUserId());
		ResultMap<WstLogMoneys> resultMap = logMoneysService.selectByUserId(paramMap);
		return resultMap;
	};
	
	@RequestMapping("/getMoney")
	@ResponseBody
	public Wallet getSession(HttpServletRequest request) {
		User user = (User) request.getSession().getAttribute("user");
		Wallet wallet = walletService.selectMoneyByUserId(user.getUserId());
		return wallet;
	}
	
}